/*************************************************************************
	> File Name: linkage.cpp
	> Author: xuwenlong
	> Mail: myxuan475@126.com 
	> Created Time: 2018年12月14日 星期五 08时59分25秒
 ************************************************************************/
#include "linkage.h"
#include <utils/socket_request.h>
#include "acquisition.h"

Linkage::Linkage(const deviceinfo_t &devinfo):
    Acquisitor(devinfo) {

}

Linkage::~Linkage()
{

}

void Linkage::Run(tConnection connector,
                  const time_t &acqtime,
                  vector<AcqItem> &listAcquire)
{
    //I/O状态
    tDataItem item;
    OpValue result;

    item = GetItemByDot("sta1001");
    if (!item.valid()) {
        m_bStat = false;
        return;
    }

    if (0 != acquireDevice(connector,item,result,NULL)) {
        m_bStat = false;
        return;
    }

    AcqItem acqItem = result;
    acqItem.SetId(item->GetItemId());
    acqItem.SetName(item->GetName());
    listAcquire.push_back(acqItem);

    //联动控制
    OpValue *value = acqItem.Value(NULL);
    while(value) {
        if (value->IsInteger() && value->Integer() == 1) {
            //发现出了异常
//            AcquisitionManager *acqMgr = (AcquisitionManager*)GetTask(DAS_ACQUISITOR);
//            acqMgr->indicateDevice(5204,"ctrl514",0);
        }

        value = acqItem.Value(value);
    }
}

S32 Linkage::commitData(S32 timeout)
{
    return -1;
}
